﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;



namespace cbFileManager.Handlers
{
    sealed class UIhandlers
    {
       

        public static void  ClickAddNewImage(object sender, EventArgs e)
        {

            OpenFileDialog opDialog = new OpenFileDialog();

            if (opDialog.ShowDialog() == DialogResult.OK)
            {
                
                Manager.ImageHandler.lBox.Items.Add(Manager.Convertion.getFile(opDialog.FileName));
                Manager.ImageHandler.StoreImage(opDialog.FileName);
                Manager.ImageHandler.ImageString(Manager.Convertion.getFile(opDialog.FileName));

                               
            }

 

        }


        public static void ClickRemoveImage(object sender, EventArgs e)
        {
            if (Manager.ImageHandler.lBox.SelectedIndex == -1)
            {

                MessageBox.Show("Você Precisa Selecionar para poder apagar!", "Aviso:", MessageBoxButtons.OK, MessageBoxIcon.Information);


            }
            else
            {

                
                Manager.ImageHandler.lBox.Items.RemoveAt(Manager.ImageHandler.lBox.SelectedIndex);
                Manager.ImageHandler.Thumbs.RemoveAt(Manager.ImageHandler.lBox.SelectedIndex + 1);
                Manager.ImageHandler.StringThumb.RemoveAt(Manager.ImageHandler.lBox.SelectedIndex + 1);



            }


        }


        public static void SaveFileButton(object sender, EventArgs e)
        {
            SaveFileDialog save = new SaveFileDialog();

            save.Filter = "Cb Sprites|*.cbspr|Cb Sound|*.cbsnd|CbAnimation|*.cbanim";
            if (save.ShowDialog() == DialogResult.OK)
            {

               // Manager.WriteFile.pFilePath = save.InitialDirectory;
                //Manager.WriteFile.pFileName = save.FileName;
                //Manager.WriteFile.doWriteFile(Manager.ImageHandler.Thumbs);
                Manager.Compress.CompressFiles nCompress = new Manager.Compress.CompressFiles();
                //nCompress.pFileName = save.InitialDirectory + save.FileName;
                nCompress.WriteToFile(Manager.ImageHandler.Thumbs, Manager.ImageHandler.StringThumb, save.InitialDirectory + save.FileName, true);
                

            }

        }


    }


}